#ifndef THREAD_H
#define THREAD_H
#include <pthread.h>
#include <event.h>
#include "queue.h"

typedef struct {
	pthread_t id;        /* unique ID of this thread */
	struct event_base *base;    /* libevent handle this thread uses */
	struct event notify_event;  /* listen event for notify pipe */
	int notify_receive_fd;      /* receiving end of notify pipe */
	int notify_send_fd;         /* sending end of notify pipe */
	int nconn;                  /* number of connection */
	pthread_mutex_t lock;  /* mutex of nconn */
	queue_t *conns;
}thread_t;

extern void thread_init(int number);
extern thread_t *thread_select(void);
extern void thread_nconn_add(thread_t *th);
extern void thread_nconn_del(thread_t *th);
#endif
